﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChineseSchool.BLL;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.UserControl.ThuNghiem
{
    public partial class PopularPost : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            lblNews.Text = LoadNewsContent();
        }

        public string LoadNewsContent()
        {
            const string format = "ddd, dd/MM/yyyy";
            var strNews = "";
            var lstNews = (new B_News()).GetTop10News(5);
            if (lstNews != null && lstNews.Count > 0)
            {
                strNews += "<ul>";
                foreach (var news in lstNews)
                {

                    strNews += "<li>";
                    strNews += "    <img  src=\"" + news.imageUrl + "\" title=\"" + news.title + "\" alt=\"" + news.title + "\">";
                    strNews += "    <a href=\"" + Util.MakeLinkNewsDetail(news.newsID.ToString(CultureInfo.InvariantCulture), Encode.Uni2KD(news.title)) + "\">" + news.title + "</a>";
                    strNews += "    <div class=\"date-like-comment\">";
                    strNews += "         <span class=\"date\">" + news.postDate.ToString(format) + "</span>";
                    strNews += "        <a class=\"like\" href=\"#\"><i class=\"fa fa-thumbs-o-up\"></i>08</a>";
                    strNews += "        <a class=\"comments\" href=\"#\"><i class=\"fa fa-comments-o\"></i>49</a>";
                    strNews += "    </div>";
                    strNews += "</li>";

                }
                strNews += "</ul>";
            }
            return strNews;
        }
    }
}